#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "sdlImage.h"

using std::string;

sdlImage::sdlImage(){
	this->surface = NULL;
}

sdlImage::sdlImage(string path){
	this->surface = NULL;
	this->load(path);
}

bool sdlImage::load(string path){
	if (this->surface != NULL){
		SDL_FreeSurface(this->surface);
	}
	SDL_Surface* loadedImage = NULL;
	loadedImage = IMG_Load(path.c_str());
	if (loadedImage == NULL){return false;}
	this->surface = SDL_DisplayFormat(loadedImage);
	SDL_FreeSurface(loadedImage);
	if (this->surface == NULL){return false;}
	return true;
}

sdlImage::~sdlImage(){}
